package com.etcfg.etlaunch;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.Shape;
import java.awt.font.FontRenderContext;
import java.awt.font.TextLayout;
import java.awt.geom.AffineTransform;

import javax.swing.JFrame;
import javax.swing.SwingUtilities;

public class TestColorDraw {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		SwingUtilities.invokeLater(new Runnable() {

			@Override
			public void run() {
				final JFrame frame = new JFrame() {
					@Override
					public void paint(Graphics g) {

						int w = getWidth();
						int h = getHeight();
						Graphics2D g2 = (Graphics2D) g;
						Color color = g2.getBackground();
						g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
								RenderingHints.VALUE_ANTIALIAS_ON);
						// g2.setRenderingHint(RenderingHints.KEY_RENDERING,
						// RenderingHints.VALUE_RENDER_QUALITY);
						FontRenderContext frc = g2.getFontRenderContext();
						Font f = new Font("Helvetica", 0, 13);
						String s = new String("Clanserver");
						TextLayout textTl = new TextLayout(s, f, frc);
						AffineTransform transform = new AffineTransform();
						Shape outline = textTl.getOutline(null);
						transform = g2.getTransform();

						// transform.scale(1.5, 1.5);
						transform.translate(10, 50);
						g2.setFont(f);

						g2.transform(transform);

						g2.setColor(Color.LIGHT_GRAY);
						g2.setStroke(new BasicStroke(3f));
						g2.draw(outline);

						g2.setColor(Color.WHITE);
						g2.fill(outline);

						Rectangle bounds = outline.getBounds();
						g2.setColor(color);
						g2.setStroke(new BasicStroke(1f));
						g2.draw(bounds);

						// g2.setTransform(new AffineTransform());
						// g2.setColor(Color.WHITE);
						// g2.drawString("Clanserver", 10, 50);
						// g2.drawString("Clanserver", 10, 80);

					}
				};
				frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
				frame.setSize(400, 200);
				frame.setVisible(true);

			}
		});

	}

}
